//
//  UIImage+Additions.h
//  ZDComponents
//
//  Created by zhuchao on 13-12-19.
//  Copyright (c) 2013年 baidu. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIImage (Additions)
- (UIImage *)colorizeWithColor:(UIColor *)color;//覆盖一个颜色
- (UIImage *)highLightColor;//覆盖一个高光色
- (UIImage *)mirroredImage;//镜像翻转图像
+ (UIImage *)imageFromView:(UIView *)view;//view to image
+ (UIImage *)imageFromString:(NSString *)str;
+ (UIImage *)createImageWithColor:(UIColor*) color;
+ (UIImage *)createRadialGradientImageWithSize:(CGSize)size
                                         colors:(NSArray *)colors
                                      locations:(CGFloat *)locations;


/**
 创建渐变色图片

 @param size 大小
 @param colors 渐变色(UIColor,CGColor)
 @param start 开始位置 {0,0} ~ {1,1}
 @param end 结束位置 {0,0} ~ {1,1}
 @param cornerRadius 圆角
 @param locations(NSNumber) 颜色分布，为空则均匀分布
 */
+ (UIImage *)gradientImageWithSize:(CGSize)size
                            colors:(NSArray *)colors
                        pointStart:(CGPoint)start
                               end:(CGPoint)end
                      cornerRadius:(CGFloat)cornerRadius
                         locations:(NSArray *)locations;

/**
 [self gradientImageWithSize:size colors:colors pointStart:CGPointZero end:CGPointMake(1, 1) cornerRadius:size.height / 2 locations:nil];
 */
+ (UIImage *)gradientRoundedCornerImageWithSize:(CGSize)size
                                         colors:(NSArray *)colors;

@end

#pragma mark - Alpha
@interface UIImage (Alpha)
- (BOOL)hasAlpha;
- (UIImage *)imageWithAlpha;
- (UIImage *)transparentBorderImage:(NSUInteger)borderSize;
- (UIImage *)imageByApplyingAlpha:(CGFloat)alpha;
@end



#pragma mark - Compression 压缩
@interface UIImage (Compression)
-(UIImage *)compression:(double)quality maxSize:(double)maxSize;
-(NSData *)dataWithQuality:(double)quality maxSize:(double)maxSize;
-(UIImage *)imageCompressForWidth:(UIImage *)sourceImage targetWidth:(CGFloat)defineWidth;
@end


#pragma mark - resize
@interface UIImage (Resize)
- (UIImage *)croppedImage:(CGRect)bounds;
- (UIImage *)thumbnailImage:(NSInteger)thumbnailSize
          transparentBorder:(NSUInteger)borderSize
               cornerRadius:(NSUInteger)cornerRadius
       interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedImage:(CGSize)newSize
     interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode
                                  bounds:(CGSize)bounds
                    interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedImageWithMaxSize: (CGSize)maxSize interpolationQuality: (CGInterpolationQuality)quality;
- (UIImage *)createNewImageWithMaxSize: (CGSize)size marginLeft: (BOOL)marginleft;
- (CGSize)getImageResizeWithMaxSize: (CGSize)maxSize;
- (UIImage *)corpImageInframe:(CGRect)frame;
+ (UIImage *)scaleImage:(UIImage *)image withNewSize:(CGSize)newSize;
@end


#pragma mark - Round Corner
@interface UIImage (RoundedCorner)
- (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize;
- (UIImage *)roundedCornerImageWithShadow:(NSInteger)shadowSize cornerSize:(NSInteger)cornerSize borderSize:(NSInteger)borderSize;
@end

@interface UIImage (Combine)

+ (UIImage *)combine:(UIImage*)leftImage rightImage:(UIImage*)rightImage space:(CGFloat)space;
+ (UIImage *)compose:(UIImage*)baseImg subImage:(UIImage *)subImg orgin:(CGPoint)subPoint;
@end
